local skel = fk.CreateSkill {
  name = "emo__chenshi",
}

Fk:loadTranslationTable{
  ["emo__chenshi"] = "陈势",
  [":emo__chenshi"] = "出牌阶段限一次，你可以翻面一张手牌并视为使用之；然后若你的明置牌数等于暗置牌数，你重置。",

  ["#emo__chenshi"] = "陈势:翻面一张手牌并视为使用之",
}

local DIY = Pcall(require, "packages/diy_utility/diy_utility")

skel:addEffect("active", {
  anim_type = "drawcard",
  prompt = "#emo__chenshi",
  card_num = 1,
  target_num = 0,
  card_filter = function (self, player, to_select, selected)
    return #selected == 0 and table.contains(player.player_cards[Player.Hand], to_select)
  end,
  can_use = function (self, player)
    return player:usedSkillTimes(skel.name, Player.HistoryPhase) == 0
  end,
  times = function (self, player)
    return 1 - player:usedSkillTimes(skel.name, Player.HistoryPhase)
  end,
  on_use = function (self, room, skillUseEvent)
    local player, cid = skillUseEvent.from, skillUseEvent.cards[1]
    if not DIY then return end
    local card = Fk:getCardById(cid)
    if table.contains(DIY.getShownCards(player), cid) then
      DIY.hideCards(player, {cid})
    else
      DIY.showCards(player, {cid})
    end
    if table.contains(player.player_cards[Player.Hand], cid) and card.sub_type ~= Card.SubtypeDefensiveRide
     and card.type ~= Card.TypeEquip and not card.is_passive then
      room:askToUseVirtualCard(player, {
        name = card.name, skill_name = skel.name,
      })
    end
    if player.dead then return end
    if #DIY.getShownCards(player) == player:getHandcardNum() / 2 then
      player:reset()
    end
  end,
})

return skel
